/**
 * 
 */
package com.audi.handler;

import android.util.SparseArray;

import com.audi.message.ActionMessage;

/**
 * @author HuyPVA
 * 
 */
public class HandlerFactory {
	public static HandlerFactory handlerFactory = new HandlerFactory();
	private SparseArray<Handler> handlerList;

	private HandlerFactory() {
		handlerList = new SparseArray<Handler>();
		
		handlerList.put(ActionMessage.DEVICE, new DeviceHandler());
		handlerList.put(ActionMessage.PLACE, new PlaceHandler());
		handlerList.put(ActionMessage.MEMBER, new MemberHandler());
		handlerList.put(ActionMessage.SMART_TRIGGER, new SmartTriggerHandler());
		handlerList.put(ActionMessage.SCENE, new SceneHandler());
		handlerList.put(ActionMessage.HISTORY, new HistoryHandler());
		handlerList.put(ActionMessage.ERROR, new ExeptionHandler());
	}

	public static HandlerFactory getInstance()
	{
		return handlerFactory;
	}
	/**
	 * Get handler by actionId
	 * 
	 * @param actionId
	 * @return
	 */
	public Handler getHandler(int actionId) {
		return getInstance().handlerList.get(actionId / 1000);
	}
}
